#include<bits/stdc++.h>
#define all(a) a.begin(), a.end()
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using pii = std::pair<int, int>;
using vii = std::vector<pii>;
using vi = std::vector<i64>;

//std::mt19937 rng {std::chrono::steady_clock::now().time_since_epoch().count()};

int main() {
	
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	int n;
	std::cin >> n;
	vi a(n), b(n - 1);
	for(int i = 0; i < n; i++) {
		std::cin >> a[i];
		if(i) {
			b[i - 1] = a[i] - a[i - 1];
		}
	}

	i64 ans = n;
	int p = 0;
	for(int i = 0; i < n - 1; i++) {
		while(p + 1 < n - 1 && b[p + 1] == b[i]) {
			p++;
		}
		ans += (p - i + 1);
	}
	std::cout << ans;


	return 0;
}